<?
include ('../config.php');

$id 	= 'userid';
$vname 	= 'users'; 
$cid = $_REQUEST[$id];

$form = new form();
$form->table = "users";
$form->action = $config['submit_url'];

$form->include = array("first name"=>"firstname",
                       "Last name"=>"lastname",
                       "Birthday"=>"dob",
                       "type"=>array("type"=>"select","id"=>"utypeid","v"=>"name","query"=>"select utypeid,name from utypes"),
                       "Bank Account number"=>"acctno",
                       "username"=>"user",
                       "active"=>array("type"=>"cselect","query"=>array("0"=>"inactive","1"=>"active"),"id"=>"active","v"=>"active")
);



if(!$cid){
	$form->title 		= "Add new ".$vname;
	$form->submit 		= "Add ".$vname;
}else{
	$form->title 		= "Edit ".$vname;
	$form->submit 		= "Edit ".$vname;
	$form->index 		= $cid;
	$form->indexname	= $id;
	$form->Addnew		= array('url'=>$_SERVER['PHP_SELF'],'text'=>'Add New '.$vname);
}
$parse = $form->CreateForm();
echo $parse;

$view = new view();
//creating the view
$view->title 						= "Current defined ".$vname;
$view->query 						= "select users.".$id.",firstname,lastname,dob,utypes.name,acctno,user,active,pass  from ".$form->table." left outer join utypes on (users.utypeid = utypes.utypeid)";
$view->properties['headers'] 		= array($vname.' ID'=>"","first Name"=>"", "last name"=>"","dob"=>"","type"=>"", "account number"=>"","username"=>"","active"=>"","encrypted pass"=>"");
$view->properties['cols']			= '10';
$view->properties['editurl']		= $_SERVER['PHP_SELF'];
$view->properties['editparam']  	= array($id=>'##'.$id.'##');
$view->properties['deleteurl']		= $config['submit_url'];
$view->properties['deleteparam']	= array('index'=>'##'.$id.'##','indexname'=>$id,'submit'=>'DELETE','t'=>$form->table);
$parse = $view->CreateView();
echo $parse;
?>
<a href='utypes.php'>Manage user types</a><BR>
<a href='permissions.php'>Manage user permissions</a><BR>
<a href='index.php'>Home</a>